<?php


namespace app\admin\controller\v1;


use app\common\controller\BaseController;
use app\common\model\Agreement as AgreementModel;

class Agreement extends BaseController
{
    //自动写入时间
    protected $autoWriteTimestamp = true;

    /**
     * 获取协议列表
     * @return \think\response\Json
     */
    public function index(){
        $list = (new AgreementModel()) ->getAgreementList();
        return self::showResCode('获取成功',['list'=>$list]);
    }

    /**
     * 新增协议
     * @return \think\response\Json
     */
    public function save(){
        //验证参数(预留)
        //保存操作
        (new AgreementModel())->Mcreate();
        return self::showResCodeWithOutData('添加成功',200);
    }

    /**
     * 编辑协议
     */
    public function update()
    {
        //验证参数（预留）
        //编辑操作
        $data = (new AgreementModel())->updateAgreement();
       return self::showResCode('修改成功',$data);
    }

    /**
     * 删除单条协议
     * @return \think\response\Json
     */
    public function delete()
    {
        $data = (new AgreementModel())->deleteOneAgreement();
        return self::showResCode('删除成功',$data);
    }
}